from flask import Flask, request, views, session, redirect

app = Flask(__name__)


@app.before_request
def before(*args, **kwargs):
    if request.path=="login":
        return None
    else:
        name=session.get("user")
        if not name:
            return redirect("login")
        else:
            return None

@app.after_request
def after(respose):
    pass

@app.before_first_request
def first():
    print("my first")

if __name__ == "__main__":
    app.run(debug=True)